//
//  YSBookChapterContentModel.h
//  YSBookRead
//
//  Created by Kyson on 2018/11/6.
//  Copyright © 2018 YangShen. All rights reserved.
//

#import <Foundation/Foundation.h>

extern NSString * const YSBookChapterContentLoadingTip;

@class YSBookChapterModel;

@interface YSBookChapterContentModel : NSObject

/// BookID
@property (nonatomic, copy) NSString *bookID;
/// 章节数
@property (nonatomic, assign) NSInteger chapterIndex;
/// 章节ID
@property (nonatomic, copy) NSString *chapterID;
/// 上一章 章节ID
@property (nonatomic, copy) NSString *prevChapterID;
/// 下一章：章节ID
@property (nonatomic, copy) NSString *nextChapterID;
/// 章节名称
@property (nonatomic, copy) NSString *chapterName;
/// 章节URL地址，针对网络小说
@property (nonatomic, copy) NSString *chapterURL;

/// 章节内容是否有缓存
@property (nonatomic, assign) BOOL haveCache;
/// 章节内容是否加载进内存
@property (nonatomic, assign) BOOL isLoad;

/// 章节内容
@property (nonatomic, copy) NSString *content;
/// 章节页数
@property (nonatomic, assign, readonly) NSInteger pageCount;
/// 每一页的Range数组
@property (nonatomic, strong, readonly) NSArray <NSNumber *> *pageRangeArray;

/// 通过章节模型初始化
+ (instancetype)bookChapterContentModelWith:(YSBookChapterModel *)bookChapterModel;

/// 清除内容(释放内存)
- (void)releaseChapter;
/// 分页
- (void)updateContentPaging;
/// 获取某页的字符串
- (NSAttributedString *)getStringWith:(NSInteger)page;
/// 通过 Page 获得 Location
- (NSInteger)locationWith:(NSInteger)page;
/// 通过 Page 获得 CenterLocation
- (NSInteger)centerLocationWith:(NSInteger)page;
/// 通过位置获取当前页
- (NSInteger)pageWith:(NSInteger)location;

@end
